﻿function InitBackup() {
    List();
}

function List() {
    ajax("ListDatabaseBackup", {}, function (obj) {
        $("#tb_list tr:not(:first)").remove();
        $("#tb_list").append("#tmpl_list", obj);
    });
}

function ajax(method, param, success) {
    $.ajax({
        url: "../System_Db/Backup.aspx?m=" + method + "&rnd=" + Math.random()
        , dataType: "json"
        , type: "post"
        , data: param
        , success: function (data) {

            if (!AjaxError(data)) {
                success(data);
            }
        }
        , error: function (r) {
            alert(r.responseText);
        }
    });
};

function Backup() {
    ajax("BackupDb", { name: $("#name").val() }, function (obj) {
        if (obj.success - 0 == 1) {
            alert("备份成功");
            List();
        }
        else {
            alert(obj.msg);
        }
    });
}

function Restore(order) {
    ajax("RestoreDb", { order: order }, function (obj) {
        if (obj.success - 0 == 1) {
            alert("恢复成功");
            List();
        }
        else {
            alert(obj.msg);
        }
    });
}

function InitRestore() {
    List();
}